﻿// -----------------------------------------------------------------------
// <copyright file="CreateNewGarageVehicle.cs" company="">
// TODO: Update copyright text.
// </copyright>
// -----------------------------------------------------------------------

namespace Ex03.GarageLogic
{
    using System;
    using System.Collections.Generic;
    using System.Text;

    public enum eVehicleType
    {
        Motorcycle = 1,
        Car,
        Truck
    }

    /// <summary>
    /// TODO: Update summary.
    /// </summary>
    internal static class GarageVehicleFactory
    {
        #region Messsages
        private const string k_VehicleTypeDoesntExist = @"That vehicle type and engine doesn't exist.";
        #endregion

        #region Consts
        private static readonly float r_MaxFuelMotorcycle = 7f;
        private static readonly float r_MaxElerctricMotorcycle = 1.7f;
        private static readonly int r_NumOfWheelsMotorcycle = 2;
        private static readonly float r_NumOfWheelsPSIMotorcycle = 32;
        private static readonly float r_MaxFuelCar = 41f;
        private static readonly float r_MaxElerctricCar = 2.2f;
        private static readonly int r_NumOfWheelsCar = 4;
        private static readonly float r_NumOfWheelsPSICar = 30;
        private static readonly float r_MaxFuelTruck = 210f;
        private static readonly int r_NumOfWheelsTruck = 12;
        private static readonly float r_NumOfWheelsPSITruck = 27;
        #endregion

        #region Public Methods
        public static GarageVehicle CreateGarageVehicle(string i_LicenseNumber, eVehicleType i_VehicleType, eEngineType i_EnergyType)
        {
            Vehicle newVehicle = null;
            GarageVehicle newGarageVehicle = null;

            switch (i_VehicleType)
            {
                case eVehicleType.Motorcycle:
                    if (i_EnergyType == eEngineType.Fuel)
                    {
                        newVehicle = new Motorcycle(i_LicenseNumber, new FuelEngine(eFuelType.Octan96, r_MaxFuelMotorcycle), r_NumOfWheelsMotorcycle, r_NumOfWheelsPSIMotorcycle);
                    }
                    else if (i_EnergyType == eEngineType.Electric)
                    {
                        newVehicle = new Motorcycle(i_LicenseNumber, new ElectricEngine(r_MaxElerctricMotorcycle), r_NumOfWheelsMotorcycle, r_NumOfWheelsPSIMotorcycle);
                    }
                    else
                    {
                        throw new ArgumentException(k_VehicleTypeDoesntExist);
                    }

                    break;

                case eVehicleType.Car:
                    if (i_EnergyType == eEngineType.Fuel)
                    {
                        newVehicle = new Car(i_LicenseNumber, new FuelEngine(eFuelType.Octan95, r_MaxFuelCar), r_NumOfWheelsCar, r_NumOfWheelsPSICar);
                    }
                    else if (i_EnergyType == eEngineType.Electric)
                    {
                        newVehicle = new Car(i_LicenseNumber, new ElectricEngine(r_MaxElerctricCar), r_NumOfWheelsCar, r_NumOfWheelsPSICar);
                    }
                    else
                    {
                        throw new ArgumentException(k_VehicleTypeDoesntExist);
                    }

                    break;

                case eVehicleType.Truck:
                    if (i_EnergyType == eEngineType.Fuel)
                    {
                        newVehicle = new Truck(i_LicenseNumber, new FuelEngine(eFuelType.Soler, r_MaxFuelTruck), r_NumOfWheelsTruck, r_NumOfWheelsPSITruck);
                    }
                    else
                    {
                        throw new ArgumentException(k_VehicleTypeDoesntExist);
                    }

                    break;

                default:
                        throw new ArgumentException(k_VehicleTypeDoesntExist);
            }

            newGarageVehicle = new GarageVehicle(newVehicle);

            return newGarageVehicle;
        }
        #endregion
    }
}
